.PHONY: all
all: install_diagd install_server

UDEV := $(shell pkg-config --cflags --libs libudev)
SYSTEMD := $(shell pkg-config --cflags --libs libsystemd)

diagd: main.c log.c test.c tool.c work.c led.c
	gcc -g ${UDEV} ${SYSTEMD} -lpthread -o diagd main.c log.c test.c tool.c work.c led.c

install_diagd: diagd diagd.service conf
	cp diagd /usr/bin/
	cp ./config /etc/autoTest.conf
	cp diagd.service /etc/systemd/system/
	systemctl daemon-reload

install_server: conf server.service
	cp server.service /etc/systemd/system/
	cp ./config /etc/autoTest.conf
	systemctl daemon-reload

PWD := $(shell pwd)
DIR := $(shell dirname ${PWD})

conf: config
	sed -i 's|DIR=.*|DIR=${DIR}|' ./config

